import { createNavigationContainerRef } from '@react-navigation/native';

type RootStackParamList = {
  home: undefined;
  user: undefined;
  login: undefined;
  webViewScreen: any;
  productSubmission: { data: IGetBtnDefaultGoodsRes };
  healthClock: undefined;
  propertyPayment: undefined;
  fireDetection: undefined;
  selectMapPoint: { backScreen: string };
  activityApply: undefined;
  informDetails: undefined;
  trappedReport: undefined;
  sendNotify: undefined;
  merchantProduct: undefined;
  rescueProgress: {orderId:number};
  orderEvaluate: {orderId:number};
  productDetails: { product: IProductInformation; hasAddedToCart?: boolean };
};

export const navigationRef = createNavigationContainerRef<RootStackParamList>();

export function navigate<RouteName extends keyof RootStackParamList>(name: RouteName, params?: RootStackParamList[RouteName]) {
  if (navigationRef.isReady()) {
    // @ts-ignore
    navigationRef.navigate(name, params);
  }
}
